package org.example.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @author zfj
 * @date 2022/4/22 -13:45
 * 连接工厂创建信道的工具类
 */
public class RabbitMqUtils {
	//得到一个连接的 channel
	public static Channel getChannel() throws Exception {
		//创建连接工厂
		ConnectionFactory factory = new ConnectionFactory();
		//设置工厂IP 连接RabbitMQ的队列
		factory.setHost("192.168.78.135");
		//用户名
		factory.setUsername("admin");
		//密码
		factory.setPassword("admin");
		Connection connection = factory.newConnection();
		//获取信道
		Channel channel = connection.createChannel();
		return channel;
	}

}
